//
//  TakeUntilViewController.swift
//  testRxSwift
//
//  Created by 火星人 on 2017/7/25.
//  Copyright © 2017年 火星人. All rights reserved.
//

import UIKit
import RxSwift

class TakeUntilViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
 
        self.view.addTapWithHandle { (tap) in
            
            let dbag = DisposeBag()
            
            let sourceSequence = PublishSubject<String>()
            let referenceSequence = PublishSubject<String>()
            
            sourceSequence.takeUntil(referenceSequence)
                .subscribe({ (eve) in
                    print(eve)
                })
                .disposed(by: dbag)
            
            sourceSequence.onNext("1")
            sourceSequence.onNext("2")
            
            referenceSequence.onNext("21")
            referenceSequence.onNext("22")

            sourceSequence.onNext("3")

        }
    }
}
